import inspect
import os
import logging

from enum import Enum, auto


class ConnectionCode(Enum):
    CONNECT_EXCEPTION = (300,)
    ARGUMENTS_NONE = (400,)
    CONFIG_ERROR = (500,)


class ConnectionStatus(Enum):
    DISCONNECTED = 0
    CONNECTING = 1
    CONNECTED = 2
    FAILED = 3


def print_with_location(message):
    # 获取当前的堆栈帧
    frame = inspect.currentframe().f_back
    # 获取文件名和行号
    filename = frame.f_code.co_filename
    line_number = frame.f_lineno

    # 只取文件名部分
    filename = os.path.basename(filename)

    # 打印信息，格式为：文件名:行号 信息
    print(f"[{filename}:{line_number}] {message}")
